package zifuchuan;

/**
 * 获取一个字符串在另一个字符串中的出现次数
 * "ab"
 * "abkkcadkabkebfkabkskab"
 */

public class _014出现次数 {
    static int count = 0;
    public static void main(String[] args) {
        String aim = "ab";
        String template = "abkkcadkabkebfkabkskab";
        int count = getCount(aim.length(), aim, template);
        System.out.println(count);
    }
    public static int getCount(int length,String aim,String template){
        for (int i = 0 ; i <= template.length()-length ;i++){
            if (template.substring(i,i+length).equals(aim)){
                count ++;
            }
        }
        return count;
    }
}
